/*
	Copyright (c) 2008, Hilaver
	@version: 0.1
	@author Shi Dafei
*/

var i18nMessage = function(url){
	this.load(url);
};

i18nMessage.prototype = {
	xml: null,
	
	load:function(url){
		if(window.ActiveXObject){
	        this.xml = new ActiveXObject('Msxml2.DOMDocument');
		}else if (document.implementation&&document.implementation.createDocument){
	        this.xml = document.implementation.createDocument('', '', null);
		}
		
		this.xml.async = false;
	    this.xml.load(url);
		var lang = this.get('locale');
		if(lang.indexOf('zh') != -1){
			document.write('<script type="text/javascript" src="../../scripts/ext/locale/ext-lang-zh_CN.js"></script>');
		}else if(lang.indexOf('fr') != -1){
			document.write('<script type="text/javascript" src="../../scripts/ext/locale/ext-lang-fr.js"></script>');
		}else{
			document.write('<script type="text/javascript" src="../../scripts/ext/locale/ext-lang-en.js"></script>');
		}
		
		
		return this.xml;
	},
	
	getValueFromTagName: function(tagName){
		var returnValue = '';
		if(this.xml.getElementsByTagName(tagName).length > 0){
			if(this.xml.getElementsByTagName(tagName)[0].firstChild && this.xml.getElementsByTagName(tagName)[0].firstChild != null)
				returnValue = this.xml.getElementsByTagName(tagName)[0].firstChild.data;
		}
		return returnValue;
	},
	
	get: function(key){
		return this.getValueFromTagName(key);
	},
	
	getCtArray: function(){
		var descriptoins = this.xml.getElementsByTagName('description');
		var ctArray = new Array();
		for(var i = 0; i < descriptoins.length; i ++){
			ctArray[i] = descriptoins[i].firstChild.data
		}
		return ctArray;
	}
}

var xmlLoader = function(url){
	this.load(url);
};

xmlLoader.prototype = {
	xml: null,
	
	load: function(url){
		if (window.ActiveXObject) {
			this.xml = new ActiveXObject('Msxml2.DOMDocument');
		}
		else 
			if (document.implementation && document.implementation.createDocument) {
				this.xml = document.implementation.createDocument('', '', null);
			}
		
		this.xml.async = false;
		this.xml.load(url);
		return this.xml;
	},
	
	getXml: function(){
		return this.xml;
	}
}
